import instance from '@/utils/request'
import store from '@/store'

// 加入购物车请求
const token = store.getters.isLogin
export const addCart = (goodsId, goodsNum, goodsSkuId) => {
  return instance({
    url: '/cart/add',
    method: 'POST',
    headers: {
      'Access-Token': token,
      platform: 'H5'
    },
    params: {
      goodsId,
      goodsNum,
      goodsSkuId
    }
  })
}

// 添加商品到购物车
export const addGoods = (goodsId, goodsNum, goodsSkuId) => {
  return instance({
    url: '/cart/add',
    headers: {
      'Access-Token': token,
      platform: 'H5'
    },
    method: 'POST',
    data: {
      goodsId,
      goodsNum,
      goodsSkuId
    }
  })
}

// 删除购物车商品
export const delGoods = (cartIds) => {
  return instance({
    url: '/cart/clear',
    method: 'POST',
    headers: {
      'Access-Token': token,
      platform: 'H5'
    },
    data: {
      cartIds
    }
  })
}
